home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
2614.ZIP
/
TBROWS.ZIP
/
TTBR5.PRG
< prev
next >
Wrap
Text File
|
1990-10-26
|
3KB
|
155 lines
/*****
*
* TTBR5.PRG
* Fifth example for TBROWSE class using a database file
*
* 20 October 90
* Luiz Quintela - Nantucket Corp
*
* Clipper ttbr5 /N/W/A/B
* RTLINK FILE ttbr5 PLL base50
*
*/
// Include Header Files
#include "inkey.ch"
#include "setcurs.ch"
FUNCTION Main()
LOCAL b, column, nKey, aColors
SET SCOREBOARD OFF
SET DATE BRITISH
SET CONFIRM ON
USE test INDEX test NEW
// Turn cursor off
SETCURSOR(SC_NONE)
SETCOLOR( "BG/B" ); CLS
b := TBrowseDB( 2, 2, 20, 48)
// Now, we will use some colors for this column
// You will use the instance variable colorSpec, which contains a
// character string defining a color table to the browse display.
// As a default, the current SETCOLOR is copied into this
// variable
b:colorSpec := "BG/B,GR+/R,W/N,N,GR+/W,G/B,R+/B,GR+/B"
b:colSep := " │ "
b:headSep := "═╤═"
b:footSep := "═══"
// TBColumn objects
column := TBColumnNew( "Field 1", {|| test->fld1} )
column:footing := "First"
b:addColumn( column )
column := TBColumnNew( "Field 2", {|| test->fld2} )
b:addColumn( column )
column := TBColumnNew( "Field 3", {|| test->fld3} )
b:addColumn( column )
column := TBColumnNew( "Field 4", {|| test->fld4} )
b:addColumn( column )
// defColor contains an array of numeric indexes into the color
// table. The first determines the unselected color which
// determines the color used to headings, footings, etc.
// It is also used to display values when the cursor is not
// on the data value being displayed.
// The second value determines the selected color which is used
// to display the current browse cell
// Note that colors set using tBColumn:colorBlock overrides those
// set by TBColumn:defColor
column := TBColumnNew( "Field 5", {|| test->fld5} )
column:colorBlock := { |y| IF(y < 4, { 6, 2 },;
IF(y > 5, { 7, 2 }, { 8, 2 } )) }
column:footing := "Last"
b:addColumn( column )
// Freeze one column
b:freeze := 1
WHILE .T.
// Do not allow cursor to move into frozen columns
IF ( b:colPos <= 1 )
// As you can see b:colPos is assignable
b:colPos := b:freeze + 1
ENDIF
// Stabilization
WHILE ( !b:stabilize() )
nKey := InKey()
IF ( nKey != 0 )
EXIT // abort if a key is waiting
ENDIF
END
IF ( b:stable )
// Is always a good idea tell the user about end or
// beginning of file
IF ( b:hitTop .OR. b:hitBottom )
TONE(87.3,1)
TONE(40,3.5)
ENDIF
// everything's done; just wait for a key
nKey := INKEY(0)
ENDIF
// Process key
IF ( nKey == K_DOWN )
b:down()
ELSEIF ( nKey == K_UP )
b:up()
ELSEIF ( nKey == K_PGDN )
b:pageDown()
ELSEIF ( nKey == K_PGUP )
b:pageUp()
ELSEIF ( nKey == K_CTRL_PGUP )
b:goTop()
ELSEIF ( nKey == K_CTRL_PGDN )
b:goBottom()
ELSEIF ( nKey == K_RIGHT )
b:right()
ELSEIF ( nKey == K_LEFT )
b:left()
ELSEIF ( nKey == K_HOME )
b:home()
ELSEIF ( nKey == K_END )
b:end()
ELSEIF ( nKey == K_CTRL_LEFT )
b:panLeft()
ELSEIF ( nKey == K_CTRL_RIGHT )
b:panRight()
ELSEIF ( nKey == K_CTRL_HOME )
b:panHome()
ELSEIF ( nKey == K_CTRL_END )
b:panEnd()
ELSEIF ( nKey == K_ESC )
CLS; SETCURSOR(SC_NORMAL); QUIT
ENDIF
END
/* EOF - TTBR5.PRG */